package org.example.table_type;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.TableResult;

public class FlinkBatchCreateAppendTable {
    public static void main(String[] args) throws Exception {
        // 使用批处理模式创建TableEnvironment
        EnvironmentSettings settings = EnvironmentSettings
                .newInstance()
                .inBatchMode() // 设置为批处理模式
                .build();
        TableEnvironment tableEnv = TableEnvironment.create(settings);

        // 创建Paimon catalog
        String createCatalogSQL = "CREATE CATALOG paimon WITH (\n" +
                "    'type' = 'paimon',\n" +
                "    'warehouse' = 'file:///tmp/paimon'\n" +
                ");";
        System.out.println("执行SQL: \n" + createCatalogSQL);
        tableEnv.executeSql(createCatalogSQL);

        // 创建非
        String createTableSQL = "CREATE TABLE `paimon`.`default`.`my_append_table` (a INT,b STRING)";
        System.out.println("执行SQL: \n" + createTableSQL);
        tableEnv.executeSql(createTableSQL);
        
        // 确保所有操作都已经完成
        System.out.println("查询执行完毕");
    }
}